<script setup>
import { chatTxtHandle } from '@/utils/chat-txt'
import { ref } from "vue";

const props = defineProps({
  content: String
})

const messages = ref(chatTxtHandle(props.content))
</script>

<template>
  <view v-for="(item, index) in messages" :key="index">
    <text v-if="item.type === 'txt'">{{ item.txt }}</text>
    <view v-else-if="item.type === 'code'" class="code-box">
      <view class="copy">复制</view>
      <text >{{ item.txt }}</text>
    </view>
  </view>
</template>

<style scoped lang="scss">
.code-box {
  background: #ececec;
  padding: 60upx 20upx 20upx 20upx;
  position: relative;
}

.copy {
  position: absolute;
  right: 10upx;
  top: 5upx;
  color: #1892e0;
  font-size: 28upx;
}
</style>